<f:view xmlns="http://www.w3.org/1999/xhtml"
	xmlns:c="http://java.sun.com/jsp/jstl/core"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:a4j="http://richfaces.org/a4j"
    xmlns:rich="http://richfaces.org/rich"
	xmlns:p="http://primefaces.prime.com.tr/ui" contentType="text/html">

<html>
	
	<h:head> 
		<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
		<h:outputStylesheet library="css" name="myform.css" />
		<h:outputScript library="jquery" name="jquery-1.2.6.js" />
		<h:outputScript library="jquery/imob" name="super.js" />
		<title> Rede de Imóveis </title>	
	</h:head>

<h:body>
	<h2>Cadastrar Corretor</h2>
	<hr />
	<h:form prependId="false" >
		<h:messages />
		
		<div id="form" >
			<p>
				<label title="nome" >Nome:</label>
				<p:inputText id="nome" required="true" size="30" value="#{pessoaBO.pessoa.nome}" />
			</p>	
			
			<p class="side">
				<span class="left">
					<label title="sexo" >Sexo:</label>
					<h:selectOneMenu id="sexo" value="#{pessoaBO.pessoa.sexo}" 
									styleClass="ui-inputfield ui-widget ui-state-default ui-corner-all side">
								<f:selectItems value="#{pessoaBO.sexos}" />
					</h:selectOneMenu>
				</span>
				<span class="right">
					<label title="ecivil" >Estado Civil:</label>
					<h:selectOneMenu id="ecivil" value="#{pessoaBO.pessoa.estadoCivil}" 
									styleClass="ui-inputfield ui-widget ui-state-default ui-corner-all side">
								<f:selectItems value="#{pessoaBO.ECivis}" />
					</h:selectOneMenu>
				</span>
			</p>
			
			<p>
				<label title="sobrenome" >Sobrenome:</label>
				<p:inputText title="sobrenome" value="#{pessoaBO.pessoa.sobrenome}"  
							required="true" size="30"/>
			</p>
				
			<p>
				<label title="creci" >Creci:</label>
				<p:inputText id="creci" value="#{pessoaBO.corretor.creci}" 
							required="false" size="30"/>
			</p>
			
			<p>
				<label title="regime" >Regime:</label>
				<h:selectOneMenu id="regime" value="#{pessoaBO.pessoa.regime}" 
								styleClass="ui-inputfield ui-widget ui-state-default ui-corner-all">
							<f:selectItems value="#{pessoaBO.regimes}" />
				</h:selectOneMenu>
			</p>
			
			<p>
				<label title="rg" >Rg:</label>
				<p:inputText title="rg" size="10" value="#{pessoaBO.pessoa.rg}"/>
			</p>
			<p>
				<label title="cpf" class="side" >Cpf:</label>
				<p:inputMask title="cpf" value="#{pessoaBO.pessoa.cpf}" 
							mask="999.999.999-99" styleClass="sides" required="true" />
			</p>
			
			<p>
				<label title="nascimento" >Nascimento:</label>
				<p:inputMask id="nascimento" value="#{pessoaBO.pessoa.nascimento}" 
							 mask="99/99/9999" size="13" />
			</p>
				
			<p>
				<label title="login" >User:</label>
				<p:inputText id="login" value="#{pessoaBO.login.login}"
							required="true" size="10" />
			</p>
				
			<p class="recoil">
				<label title="senha" >Senha:</label>
				<p:password title="senha" value="#{pessoaBO.login.senha}"
							size="10" required="true"/>
			</p>
			
			<p>
				<label title="email" >Email:</label>
				<p:inputText title="email" value="#{pessoaBO.login.email}" 
							required="true" size="30"/>
			</p>
			
			<p>
				<label title="site" >Site:</label>
				<p:inputText title="site" value="#{pessoaBO.login.site}"
							required="false" size="30"/>
			</p>
			
			<p>
				<label title="fone" >Telefone:</label>
				<p:inputMask title="fone" value="#{pessoaBO.contato.telefone}" 
							required="false" mask="(99) 9999-9999"/>
			</p>
			<p>
				<label title="comercial" >Telefone Comercial:</label>
				<p:inputMask title="comercial" value="#{pessoaBO.contato.comercial}" 
							required="false" mask="(99) 9999-9999? x99999"/>
			</p>
				
			<p>
				<label title="celular" >Celular:</label>
				<p:inputMask title="celular" value="#{pessoaBO.contato.celular}" 
							required="true" mask="(99) 9999-9999" />
			</p>
			<p>
				<label title="fax" >Fax:</label>
				<p:inputMask title="fax" value="#{pessoaBO.contato.fax}" 
							required="false" mask="(99) 9999-9999? x99999"/>
			</p>	
			
			<p>
				<label title="bairro" >Bairro:</label>
				<p:inputText title="bairro" value="#{pessoaBO.bairro.bairro}" 
							required="true" />
			</p>
							
			<p>
				<label title="estado" class="eside">Estado:</label>
				<h:selectOneMenu id="estado" immediate="true"
								value="#{pessoaBO.estado.estado}"
								styleClass="ui-inputfield ui-widget ui-state-default ui-corner-all "
								required="true">
					<f:selectItem itemLabel="Selecione Estado" itemValue="" />	
					<f:selectItems value="#{pessoaBO.listEstados}" />
					<f:ajax event="valueChange" render="cities" immediate="true" listener="#{pessoaBO.getEstadoSelected}"/>
				</h:selectOneMenu>
			</p>
			
			<p>
				<label title="cep" >Cep:</label>
				<p:inputMask title="cep" value="#{pessoaBO.bairro.cep}" 
							required="true" mask="99.999-999"/>
			</p>
	
			<p>
				<label for="cities" class="eside">Cidade:</label>
				<h:selectOneMenu id="cities" immediate="true"
								value="#{pessoaBO.cidade.cidade}"
								styleClass="ui-inputfield ui-widget ui-state-default ui-corner-all ">
							<f:converter converterId="br.com.imob.view.Object" />
							<f:selectItem itemLabel="Selecione Cidade" itemValue="" />
							<f:selectItems value="#{pessoaBO.listCidades}" var="city" itemValue="#{city.cidade}"/>
				</h:selectOneMenu>
			</p>
				
			<p>
				<label title="Endereco" >Endereco:</label>
				<p:inputText title="Endereco" value="#{pessoaBO.endereco.endereco}" size="30"/>
			</p>
			
			<p>
				<label title="foto" >Foto:</label>
				<p:fileUpload fileUploadListener="#{controller.fileUploadAction}"
				            auto="true"
				            label="Selecione..."
				            update="preview"
				            multiple="false"
				            sizeLimit="1000000"
				            allowTypes="png,gif,jpg"/>
				            
				<p:graphicImage id="preview" value="#{controller.image}" cache="false" styleClass="foto"/>
			</p>			
			
			<p>
				<label title="complemento" >Complemento:</label>
				<p:inputText title="complemento" value="#{pessoaBO.endereco.complemento}" size="30"/>
			</p>
	
			<p>
				<label title="logomarca" >Logomarca:</label>
				<p:fileUpload fileUploadListener="#{controller.fileUploadAction}"
				            auto="true"
				            label="Selecione..."
				            update="logo"
				            multiple="false"
				            sizeLimit="1000000"
				            allowTypes="png,gif,jpg"/>
				<p:graphicImage id="logo" value="#{controller.image}" cache="false" styleClass="logomarca"/>
			</p>
			
		</div>
		<div class="button">
			<h:commandButton id="btnReset" value="Limpar" type="reset"/>
			<h:commandButton id="btnCancel" value="Cancelar" type="button" />
			<h:commandButton value="Cadastrar" actionListener="#{pessoaBO.adicionarPessoa}"/>
		</div>
		
	</h:form>
</h:body>
</html>

</f:view>